﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Globalization;

using System.Numerics;

using NumDouble = MathNet.Numerics.LinearAlgebra.Double;
using NumComplex = MathNet.Numerics.LinearAlgebra.Complex;

namespace Estimador_EDAL.Interface_View
{
    public class CDiagramDataCollection
    {
        private List<CDiagramData> m_ListDiagramData;

        #region Construção do Objeto

        public CDiagramDataCollection()
        {
            Defaults();
        }

        public CDiagramDataCollection(CDiagramDataCollection diagramCollection)
        {
            Copy(diagramCollection);
        }

        public CDiagramDataCollection(List<CDiagramData> listDiagramData)
        {
            m_ListDiagramData = listDiagramData;
        }

        private void Defaults()
        {
            m_ListDiagramData = new List<CDiagramData>();
        }

        private void Copy(CDiagramDataCollection diagramCollection)
        {
            m_ListDiagramData.Clear();
            foreach (CDiagramData data in diagramCollection.m_ListDiagramData)
                m_ListDiagramData.Add(new CDiagramData(data));
        }

        public string ValidaDados(bool isReportZerado)
        {
            //falta implementar!!!!!!!!!!!!!!!!!!!!!!!
            return "";
        }

        #endregion Construção do Objeto

        #region Get's e Set's

        public ReadOnlyCollection<CDiagramData> ListDiagramData
        {
            get
            {
                return m_ListDiagramData.AsReadOnly();
            }
        }

        #endregion Get's e Set's

        #region Rotinas Públicas - Add e Remove CMedicao

        public bool AddDiagramData(CDiagramData data)
        {
            bool achou = m_ListDiagramData.Contains(data);
            if (achou)
                return false;

            m_ListDiagramData.Add(data);
            return true;
        }

        public bool RemoveDiagramData(CDiagramData data)
        {
            bool achou = m_ListDiagramData.Contains(data);
            if (!achou)
                return false;

            m_ListDiagramData.Remove(data);
            return true;
        }

        #endregion Rotinas Públicas - Add e Remove CMedicao

        #region Rotinas Públicas - DE e PARA formato texto

        public void CarregaDeTxt(string str)
        {
            string[] str_Partes = str.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (string str_Data in str_Partes)
            {
                string str_Data_Tmp = str_Data.Trim();
                if (str_Data_Tmp.StartsWith("("))
                    continue;

                CDiagramData data = new CDiagramData();
                data.CarregaDeTxt(str_Data);
                m_ListDiagramData.Add(data);
            }
        }

        public string DescarregaParaTxt(bool isReportZerado)
        {
            string ret = (isReportZerado) ? "\n\n" : "";

            ret += "Lista de DiagramData:\n\n";

            foreach (CDiagramData data in m_ListDiagramData)
                ret += data.DescarregaParaTxt() + "\n";

            return ret;
        }

        #endregion
    }
}
